package com.bhkj.pdjhbgnewproject.core.main;

import android.Manifest;
import android.content.Intent;

import com.bhkj.pdjhbgnewproject.R;
import com.bhkj.pdjhbgnewproject.common.utils.UpdateUtil;
import com.bhkj.pdjhbgnewproject.core.base.BaseActivity;
import com.bhkj.pdjhbgnewproject.core.service.ObtainPdInfoService;
import com.blankj.utilcode.util.PermissionUtils;
import com.blankj.utilcode.util.ServiceUtils;

public class MainActivity extends BaseActivity implements IMainView {


    private MainHandler mainHandler;

    @Override
    public int getLayoutId() {
        return getResources().getBoolean(R.bool.isYsd) ? R.layout.activity_main_rc : R.layout.activity_main_real;
    }


    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        ServiceUtils.startService(ObtainPdInfoService.class);
    }

    @Override
    public void initView() {
        PermissionUtils permission = PermissionUtils.permission(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE});
        permission.request();
    }

    @Override
    public void initData() {
        UpdateUtil.checkUpdate(this, true);
        if (mainHandler == null) {
            mainHandler = new MainHandler(this);
        }
        mainHandler.startAndRefreshPdInfo();
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (mainHandler != null) {
            mainHandler.onDestroy();
        }
    }

}
